package cc.rengu.oltp.service.common.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * 短信验证码类型
 * Created by 王成 on 2020/3/25
 */
public enum SmsTypeEnum {
    USER_LOGIN("01", "用户登陆"),
    USER_REGISTER("02", "用户注册"),
    SET_PASSWORD("03", "设置密码"),
    RESET_PASSWORD("04", "重置密码"),
    MODIFY_PASSWORD("05", "修改密码"),
    IDENTITY_AUTH("06", "身份认证"),
    ACCT_RECHARGE("07", "账户充值"),
    CARD_SIGN("08", "银行卡签约"),
    MODIFY_PHONE("09", "修改手机号"),
    FAST_PAYMENT("10", "快捷支付"),
    SET_TRANS_PASSWORD("11", "设置交易密码"),
    ;
    private String smsType;
    private String smsDesc;

    SmsTypeEnum(String smsType, String smsDesc) {
        this.smsType = smsType;
        this.smsDesc = smsDesc;
    }

    public String getSmsType() {
        return smsType;
    }

    public void setSmsType(String smsType) {
        this.smsType = smsType;
    }

    public String getSmsDesc() {
        return smsDesc;
    }

    public void setSmsDesc(String smsDesc) {
        this.smsDesc = smsDesc;
    }

    /**
     * 根据短信类型获取短信模板枚举值
     *
     * @param smsType 短信申请类型
     * @return 短信模板枚举值
     */
    public static TemplateTypeEnum getTemplateTypeEnum(String smsType) {
        Optional<SmsTypeEnum> smsTypeEnumOpt = Arrays.stream(SmsTypeEnum.values()).filter(item -> item.getSmsType().equals(smsType)).findFirst();
        if (smsTypeEnumOpt.isPresent()) {
            switch (smsTypeEnumOpt.get().getSmsType()) {
                case "01":
                    return TemplateTypeEnum.SMS_UEER_LGOIN;
                case "02":
                    return TemplateTypeEnum.SMS_USER_REGISTER;
                case "03":
                    return TemplateTypeEnum.SMS_SET_PASSWORD;
                case "04":
                    return TemplateTypeEnum.SMS_RESET_PASSWORD;
                case "05":
                    return TemplateTypeEnum.SMS_MODIFY_PASSWORD;
                case "06":
                    return TemplateTypeEnum.SMS_IDENTITY_AUTH;
                case "07":
                    return TemplateTypeEnum.SMS_ACCT_RECHARGE;
                case "08":
                    return TemplateTypeEnum.SMS_FAST_PAYMENT_SIGN;
                case "09":
                    return TemplateTypeEnum.SMS_MODIFY_MOBILE_NUMBER;
                case "10":
                    return TemplateTypeEnum.SMS_FAST_PAYMENT;
                case "11":
                    return TemplateTypeEnum.SMS_TRANS_PASSWORD;
                default:
                    return null;
            }
        } else {
            return null;
        }
    }
}
